﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PMC;
using PMC.Structs;

namespace PMCgui
{
    public partial class PromptForm : Form
    {
        private string previousInput = "";
        private bool numericOnly;
        private int _numeric;
        public int NumericInput { get { return _numeric; } }
        public string Input { get; private set; }

        public new string Text
        {
            get { return Input; }
        }

        public PromptForm(bool numericOnly = false)
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterParent;
            this.numericOnly = numericOnly;
            Input = "";
        }

        private void tbExpression_TextChanged(object sender, EventArgs e)
        {
            if (numericOnly && !int.TryParse(tbExpression.Text, out _numeric))
            {
                tbExpression.Text = previousInput;
            }
            previousInput = tbExpression.Text;
            Input = tbExpression.Text;
        }
    }
}
